using UnityEngine;

namespace Framework
{
    public class RandomProbability<T> : Behavior<T>
    {
        private float _successProbability;

        public RandomProbability(float successProbability)
        {
            _successProbability = successProbability;
        }
        
        public override TaskStatus Update(T context)
        {
            if (Random.Range(0f, 1f) > _successProbability)
            {
                return TaskStatus.Success;
            }
            return TaskStatus.Failure;
        }
    }
}